import { themes } from "./themes"
// 修改样式变量值
const changeStyle = (obj)=>{
  for(let key in obj){
    document.getElementsByTagName("body")[0].style.setProperty(`--${key}`, obj[key])
  }
}
export const setTheme = (themeName)=>{
  localStorage.setItem("theme", themeName);//保存主题到本地，下次进入使用该主题
  const themeConfig = themes[themeName];
  localStorage.setItem("colors", JSON.stringify(themeConfig));//保存色彩到本地，下次进入使用该主题
  changeStyle(themeConfig);
}